home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / PrintHdl.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  3.4 KB  |  112 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PrintHdl.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef PRINTHDL_H
  15. #include "PrintHdl.h"
  16. #endif
  17.  
  18. #ifndef DRAWFRM_H
  19. #include "DrawFrm.h"
  20. #endif
  21.  
  22. #ifndef DRAWCONT_H
  23. #include "DrawCont.h"
  24. #endif
  25.  
  26. #ifndef FWPART_H
  27. #include "FWPart.h"
  28. #endif
  29.  
  30. #ifndef FWPRESEN_H
  31. #include "FWPresen.h"
  32. #endif
  33.  
  34. //========================================================================================
  35. // RunTime Info
  36. //========================================================================================
  37.  
  38. #ifdef FW_BUILD_MAC
  39. #pragma segment odfdrawframes
  40. #endif
  41.  
  42. //========================================================================================
  43. // CDrawPrintHandler
  44. //========================================================================================
  45.  
  46. //----------------------------------------------------------------------------------------
  47. // CDrawPrintHandler::CDrawPrintHandler
  48. //----------------------------------------------------------------------------------------
  49. //    FALSE means I will be drawing the embedded frames. No need for the printhandler to do it
  50.  
  51. CDrawPrintHandler::CDrawPrintHandler(Environment* ev, CDrawFrame* frame, CDrawPartContent* content, FW_CPresentation* presentation) :
  52.     FW_CPrintHandler(frame, presentation, FALSE),
  53.     fDrawFrame(frame),
  54.     fPartContent(content),
  55.     fPrintPresentation(presentation)
  56. {
  57. FW_UNUSED(ev);
  58. }
  59.  
  60. //----------------------------------------------------------------------------------------
  61. // CDrawPrintHandler::~CDrawPrintHandler
  62. //----------------------------------------------------------------------------------------
  63.  
  64. CDrawPrintHandler::~CDrawPrintHandler()
  65. {
  66. }
  67.  
  68. //----------------------------------------------------------------------------------------
  69. //    CDrawPrintHandler::IsCurrentlyPrintable
  70. //----------------------------------------------------------------------------------------
  71.  
  72. FW_Boolean CDrawPrintHandler::IsCurrentlyPrintable(Environment* ev) const
  73. {
  74. FW_UNUSED(ev);
  75.     return !fPartContent->IsEmpty();
  76. }
  77.  
  78. //----------------------------------------------------------------------------------------
  79. //    CDrawPrintHandler::GetPrintContentExtent
  80. //----------------------------------------------------------------------------------------
  81.  
  82. void CDrawPrintHandler::GetPrintContentExtent(Environment *ev, long hPrinterDPI, long vPrinterDPI, FW_CPoint& extent) const
  83. {
  84. #ifndef FW_DEBUG
  85. FW_UNUSED(ev);
  86. #endif
  87.     // We only enable print command if there is anything to print
  88.     FW_ASSERT(IsCurrentlyPrintable(ev));
  89.  
  90.     // Go through all the shapes and determine their bounds
  91.     extent.Set(FW_kFixed0, FW_kFixed0);
  92.     CDrawContentShapeIterator ite(fPartContent);
  93.     for (CBaseShape* theShape = ite.First(); ite.IsNotComplete(); theShape = ite.Next())
  94.     {
  95.         FW_CRect updateBox;
  96.         theShape->GetUpdateBox(updateBox);
  97.  
  98.         if (updateBox.right > extent.x)
  99.             extent.x = updateBox.right;
  100.         
  101.         if (updateBox.bottom > extent.y)
  102.             extent.y = updateBox.bottom;
  103.     }
  104.     
  105.     FW_ASSERT(extent.x != FW_kFixed0);
  106.     FW_ASSERT(extent.y != FW_kFixed0);
  107.     
  108.     // our content is in 72 dpi, so we need to convert it to printer resolution
  109.     extent.x = extent.x * (FW_IntToFixed(hPrinterDPI) / FW_IntToFixed(72));
  110.     extent.y = extent.y * (FW_IntToFixed(vPrinterDPI) / FW_IntToFixed(72));
  111. }
  112.